package com.tyk.bookstore.back.system.util;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tyk.bookstore.back.system.manager.excel.model.PermissionExcelVo;
import com.tyk.bookstore.back.system.model.entity.MenuDo;
import com.tyk.bookstore.back.system.model.entity.PermissionDo;
import com.tyk.bookstore.back.system.model.entity.RoleDo;
import com.tyk.bookstore.back.system.model.entity.UserDo;
import com.tyk.bookstore.back.system.model.query.*;
import com.tyk.bookstore.back.system.model.vo.*;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring", implementationName = "SystemManagerMapstructSystemImpl")
public interface MapstructSystem {

    UserDo toUserDo(UpdateUserInfoQuery query);

    UserPageVo toUserPageVo(Page<UserDo> userIPage);

    List<RoleSuggestionVo> toRoleSuggestionVo(List<RoleDo> roleDos);

    UserDo toUserDo(UserAddQuery query);

    UserDo toUserDo(UserUpdateQuery query);

    RolePageVo toRolePageVo(Page<RoleDo> roleIPage);

    RoleDo toRoleDo(RoleAddQuery query);

    List<PermissionSuggestionVo> toPermissionSuggestionVo(List<PermissionDo> permissionDos);

    RoleDo toRoleDo(RoleUpdateQuery query);

    PermissionPageVo toPermissionPageVo(Page<PermissionDo> page);

    PermissionDo toPermissionDo(PermissionAddQuery query);

    PermissionDo toPermissionDo(PermissionUpdateQuery query);

    MenuListVo toGetMenuListVo(MenuDo menuDo);


    @BeanMapping(ignoreUnmappedSourceProperties = {"redirect", "component", "keepAlive"})
    MenuDo toMenuDo(MenuAddQuery query);

    @BeanMapping(ignoreUnmappedSourceProperties = {"redirect", "component", "keepAlive"})
    MenuDo toMenuDo(MenuUpdateQuery query);

    List<PermissionExcelVo> toPermissionExcelVoList(List<PermissionDo> doList);

    List<PermissionDo> toPermissionDoList(List<PermissionExcelVo> voList);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    PermissionDo toPermissionDo(PermissionExcelVo vo);
}
